﻿using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Data.SqlClient;

namespace SalePartial.Model
{
    public class XPCompanyInfo
    {
        // Methods
        public XPCompanyInfo()
        {
            this._userID = Guid.Empty;
            this._companyName = string.Empty;
            this._companyAliasName = string.Empty;
            this._industry = string.Empty;
            this._webSite = string.Empty;
            this._officePhone = string.Empty;
            this._cellPhone = string.Empty;
            this._fax = string.Empty;
            this._country = string.Empty;
            this._province = string.Empty;
            this._city = string.Empty;
            this._address = string.Empty;
            this._postCode = string.Empty;
            this._companyOwner = string.Empty;
            this._companyContact = string.Empty;
            this._companyEmail = string.Empty;
            this._licenseCertID = Guid.Empty;
            this._photo = string.Empty;
            this._logo = string.Empty;
            this._description = string.Empty;
            this._monetary = string.Empty;
            this._scale = string.Empty;
            this._fund = string.Empty;
            this._software = string.Empty;
            this._technology = string.Empty;
            this._product = string.Empty;
            this._vendorModerateUser = Guid.Empty;
            this._buyerModerateUser = Guid.Empty;
            this._moderateUser = Guid.Empty;
            this._moderateComment = string.Empty;
            this._companyID = Guid.NewGuid();
            this._createDate = DateTime.Now;
            this._isApproved = false;
            this._isLockedOut = false;
            this._officePhoneValidate = false;
            this._cellPhoneValidate = false;
            this._faxValidate = false;
            this._vendorModerateDate = new DateTime(0x7ad565b72888000L);
            this._vendorModerateUser = new Guid();
            this._vendorModerateStatus = -1;
            this._buyerModerateDate = new DateTime(0x7ad565b72888000L);
            this._buyerModerateUser = new Guid();
            this._buyerModerateStatus = -1;
            this._lastModerateDate = new DateTime(0x7ad565b72888000L);
            this._moderateUser = new Guid();
            this._moderateCount = 0;
            this._moderateComment = "";
        }

        public XPCompanyInfo(SqlDataReader reader)
        {
            this._userID = Guid.Empty;
            this._companyName = string.Empty;
            this._companyAliasName = string.Empty;
            this._industry = string.Empty;
            this._webSite = string.Empty;
            this._officePhone = string.Empty;
            this._cellPhone = string.Empty;
            this._fax = string.Empty;
            this._country = string.Empty;
            this._province = string.Empty;
            this._city = string.Empty;
            this._address = string.Empty;
            this._postCode = string.Empty;
            this._companyOwner = string.Empty;
            this._companyContact = string.Empty;
            this._companyEmail = string.Empty;
            this._licenseCertID = Guid.Empty;
            this._photo = string.Empty;
            this._logo = string.Empty;
            this._description = string.Empty;
            this._monetary = string.Empty;
            this._scale = string.Empty;
            this._fund = string.Empty;
            this._software = string.Empty;
            this._technology = string.Empty;
            this._product = string.Empty;
            this._vendorModerateUser = Guid.Empty;
            this._buyerModerateUser = Guid.Empty;
            this._moderateUser = Guid.Empty;
            this._moderateComment = string.Empty;
            this.LoadFromReader(reader);

        }

        //public XPCompanyInfo(Guid id)
        //{
        //    this._userID = Guid.Empty;
        //    this._companyName = string.Empty;
        //    this._companyAliasName = string.Empty;
        //    this._industry = string.Empty;
        //    this._webSite = string.Empty;
        //    this._officePhone = string.Empty;
        //    this._cellPhone = string.Empty;
        //    this._fax = string.Empty;
        //    this._country = string.Empty;
        //    this._province = string.Empty;
        //    this._city = string.Empty;
        //    this._address = string.Empty;
        //    this._postCode = string.Empty;
        //    this._companyOwner = string.Empty;
        //    this._companyContact = string.Empty;
        //    this._companyEmail = string.Empty;
        //    this._licenseCertID = Guid.Empty;
        //    this._photo = string.Empty;
        //    this._logo = string.Empty;
        //    this._description = string.Empty;
        //    this._monetary = string.Empty;
        //    this._scale = string.Empty;
        //    this._fund = string.Empty;
        //    this._software = string.Empty;
        //    this._technology = string.Empty;
        //    this._product = string.Empty;
        //    this._vendorModerateUser = Guid.Empty;
        //    this._buyerModerateUser = Guid.Empty;
        //    this._moderateUser = Guid.Empty;
        //    this._moderateComment = string.Empty;
        //    SqlDataReader reader = XPCompanyUtility.SelectReader(id);
        //    if (reader.Read()) {
        //        this.LoadFromReader(reader);
        //        reader.Close();
        //    } else {
        //        if (!reader.IsClosed) {
        //            reader.Close();
        //        }
        //        throw new ApplicationException("XPCompany does not exist.");
        //    }
        //}

        protected void LoadFromReader(SqlDataReader reader)
        {
            if ((!Information.IsNothing(reader) && !reader.IsClosed))
            {
                //while (reader.Read())   //ning++
                //{
                    this._companyID = reader.GetGuid(0);
                    this._userID = reader.GetGuid(1);
                    this._companyName = reader.GetString(2);
                    if (!reader.IsDBNull(3))
                    {
                        this._companyAliasName = reader.GetString(3);
                    }
                    this._industry = reader.GetString(4);
                    if (!reader.IsDBNull(5))
                    {
                        this._webSite = reader.GetString(5);
                    }
                    this._officePhone = reader.GetString(6);
                    this._officePhoneValidate = reader.GetBoolean(7);
                    this._isOfficePhonePublic = reader.GetBoolean(8);
                    if (!reader.IsDBNull(9))
                    {
                        this._cellPhone = reader.GetString(9);
                    }
                    this._cellPhoneValidate = reader.GetBoolean(10);
                    this._isCellPhonePublic = reader.GetBoolean(11);
                    if (!reader.IsDBNull(12))
                    {
                        this._fax = reader.GetString(12);
                    }
                    this._faxValidate = reader.GetBoolean(13);
                    this._isFaxPublic = reader.GetBoolean(14);
                    this._country = reader.GetString(15);
                    this._province = reader.GetString(0x10);
                    this._city = reader.GetString(0x11);
                    this._address = reader.GetString(0x12);
                    this._postCode = reader.GetString(0x13);
                    if (!reader.IsDBNull(20))
                    {
                        this._companyOwner = reader.GetString(20);
                    }
                    if (!reader.IsDBNull(0x15))
                    {
                        this._companyContact = reader.GetString(0x15);
                    }
                    if (!reader.IsDBNull(0x16))
                    {
                        this._companyEmail = reader.GetString(0x16);
                    }
                    if (!reader.IsDBNull(0x17))
                    {
                        this._isEmailPublic = reader.GetBoolean(0x17);
                    }
                    if (!reader.IsDBNull(0x18))
                    {
                        this._licenseCertID = reader.GetGuid(0x18);
                    }
                    if (!reader.IsDBNull(0x19))
                    {
                        this._photo = reader.GetString(0x19);
                    }
                    if (!reader.IsDBNull(0x1a))
                    {
                        this._logo = reader.GetString(0x1a);
                    }
                    if (!reader.IsDBNull(0x1b))
                    {
                        this._description = reader.GetString(0x1b);
                    }
                    if (!reader.IsDBNull(0x1c))
                    {
                        this._monetary = reader.GetString(0x1c);
                    }
                    if (!reader.IsDBNull(0x1d))
                    {
                        this._scale = reader.GetString(0x1d);
                    }
                    if (!reader.IsDBNull(30))
                    {
                        this._fund = reader.GetString(30);
                    }
                    if (!reader.IsDBNull(0x1f))
                    {
                        this._software = reader.GetString(0x1f);
                    }
                    if (!reader.IsDBNull(0x20))
                    {
                        this._technology = reader.GetString(0x20);
                    }
                    if (!reader.IsDBNull(0x21))
                    {
                        this._product = reader.GetString(0x21);
                    }
                    if (!reader.IsDBNull(0x22))
                    {
                        this._createDate = reader.GetDateTime(0x22);
                    }
                    this._isApproved = reader.GetBoolean(0x23);
                    this._isLockedOut = reader.GetBoolean(0x24);
                    this._vendorModerateDate = reader.GetDateTime(0x25);
                    if (!reader.IsDBNull(0x26))
                    {
                        this._vendorModerateUser = reader.GetGuid(0x26);
                    }
                    this._vendorModerateStatus = reader.GetInt16(0x27);
                    this._buyerModerateDate = reader.GetDateTime(40);
                    if (!reader.IsDBNull(0x29))
                    {
                        this._buyerModerateUser = reader.GetGuid(0x29);
                    }
                    this._buyerModerateStatus = reader.GetInt16(0x2a);
                    this._lastModerateDate = reader.GetDateTime(0x2b);
                    if (!reader.IsDBNull(0x2c))
                    {
                        this._moderateUser = reader.GetGuid(0x2c);
                    }
                    this._moderateCount = reader.GetInt32(0x2d);
                    if (!reader.IsDBNull(0x2e))
                    {
                        this._moderateComment = reader.GetString(0x2e);
                    }
                //}
            }
        }

        public static XPCompanyInfo NewXPCompany(Guid id)
        {
            return new XPCompanyInfo { _companyID = id };
        }

        // Properties
        public string Address
        {
            get { return this._address; }
            set { this._address = value; }
        }

        public DateTime BuyerModerateDate
        {
            get { return this._buyerModerateDate; }
            set { this._buyerModerateDate = value; }
        }

        public short BuyerModerateStatus
        {
            get { return this._buyerModerateStatus; }
            set { this._buyerModerateStatus = value; }
        }

        public Guid BuyerModerateUser
        {
            get { return this._buyerModerateUser; }
            set { this._buyerModerateUser = value; }
        }

        public string CellPhone
        {
            get { return this._cellPhone; }
            set { this._cellPhone = value; }
        }

        public bool CellPhoneValidate
        {
            get { return this._cellPhoneValidate; }
            set { this._cellPhoneValidate = value; }
        }

        public string City
        {
            get { return this._city; }
            set { this._city = value; }
        }

        public string CompanyAliasName
        {
            get { return this._companyAliasName; }
            set { this._companyAliasName = value; }
        }

        public string CompanyContact
        {
            get { return this._companyContact; }
            set { this._companyContact = value; }
        }

        public string CompanyEmail
        {
            get { return this._companyEmail; }
            set { this._companyEmail = value; }
        }

        public Guid CompanyID
        {
            get { return this._companyID; }
            set { this._companyID = value; }
        }

        public string CompanyName
        {
            get { return this._companyName; }
            set { this._companyName = value; }
        }

        public string CompanyOwner
        {
            get { return this._companyOwner; }
            set { this._companyOwner = value; }
        }

        public string Country
        {
            get { return this._country; }
            set { this._country = value; }
        }

        public DateTime CreateDate
        {
            get { return this._createDate; }
            set { this._createDate = value; }
        }

        public string Description
        {
            get { return this._description; }
            set { this._description = value; }
        }

        public string Fax
        {
            get { return this._fax; }
            set { this._fax = value; }
        }

        public bool FaxValidate
        {
            get { return this._faxValidate; }
            set { this._faxValidate = value; }
        }

        public string Fund
        {
            get { return this._fund; }
            set { this._fund = value; }
        }

        public string Industry
        {
            get { return this._industry; }
            set { this._industry = value; }
        }

        public bool IsApproved
        {
            get { return this._isApproved; }
            set { this._isApproved = value; }
        }

        public bool IsCellPhonePublic
        {
            get { return this._isCellPhonePublic; }
            set { this._isCellPhonePublic = value; }
        }

        public bool IsEmailPublic
        {
            get { return this._isEmailPublic; }
            set { this._isEmailPublic = value; }
        }

        public bool IsFaxPublic
        {
            get { return this._isFaxPublic; }
            set { this._isFaxPublic = value; }
        }

        public bool IsLockedOut
        {
            get { return this._isLockedOut; }
            set { this._isLockedOut = value; }
        }

        public bool IsOfficePhonePublic
        {
            get { return this._isOfficePhonePublic; }
            set { this._isOfficePhonePublic = value; }
        }

        public DateTime LastModerateDate
        {
            get { return this._lastModerateDate; }
            set { this._lastModerateDate = value; }
        }

        public Guid LicenseCertID
        {
            get { return this._licenseCertID; }
            set { this._licenseCertID = value; }
        }

        public string Logo
        {
            get { return this._logo; }
            set { this._logo = value; }
        }

        public string ModerateComment
        {
            get { return this._moderateComment; }
            set { this._moderateComment = value; }
        }

        public int ModerateCount
        {
            get { return this._moderateCount; }
            set { this._moderateCount = value; }
        }

        public Guid ModerateUser
        {
            get { return this._moderateUser; }
            set { this._moderateUser = value; }
        }

        public string Monetary
        {
            get { return this._monetary; }
            set { this._monetary = value; }
        }

        public string OfficePhone
        {
            get { return this._officePhone; }
            set { this._officePhone = value; }
        }

        public bool OfficePhoneValidate
        {
            get { return this._officePhoneValidate; }
            set { this._officePhoneValidate = value; }
        }

        public string Photo
        {
            get { return this._photo; }
            set { this._photo = value; }
        }

        public string PostCode
        {
            get { return this._postCode; }
            set { this._postCode = value; }
        }

        public string Product
        {
            get { return this._product; }
            set { this._product = value; }
        }

        public string Province
        {
            get { return this._province; }
            set { this._province = value; }
        }

        public string Scale
        {
            get { return this._scale; }
            set { this._scale = value; }
        }

        public string Software
        {
            get { return this._software; }
            set { this._software = value; }
        }

        public string Technology
        {
            get { return this._technology; }
            set { this._technology = value; }
        }

        public Guid UserID
        {
            get { return this._userID; }
            set { this._userID = value; }
        }

        public DateTime VendorModerateDate
        {
            get { return this._vendorModerateDate; }
            set { this._vendorModerateDate = value; }
        }

        public short VendorModerateStatus
        {
            get { return this._vendorModerateStatus; }
            set { this._vendorModerateStatus = value; }
        }

        public Guid VendorModerateUser
        {
            get { return this._vendorModerateUser; }
            set { this._vendorModerateUser = value; }
        }

        public string WebSite
        {
            get { return this._webSite; }
            set { this._webSite = value; }
        }


        // Fields
        private string _address;
        private DateTime _buyerModerateDate;
        private short _buyerModerateStatus;
        private Guid _buyerModerateUser;
        private string _cellPhone;
        private bool _cellPhoneValidate;
        private string _city;
        private string _companyAliasName;
        private string _companyContact;
        private string _companyEmail;
        private Guid _companyID;
        private string _companyName;
        private string _companyOwner;
        private string _country;
        private DateTime _createDate;
        private string _description;
        private string _fax;
        private bool _faxValidate;
        private string _fund;
        private string _industry;
        private bool _isApproved;
        private bool _isCellPhonePublic;
        private bool _isEmailPublic;
        private bool _isFaxPublic;
        private bool _isLockedOut;
        private bool _isOfficePhonePublic;
        private DateTime _lastModerateDate;
        private Guid _licenseCertID;
        private string _logo;
        private string _moderateComment;
        private int _moderateCount;
        private Guid _moderateUser;
        private string _monetary;
        private string _officePhone;
        private bool _officePhoneValidate;
        private string _photo;
        private string _postCode;
        private string _product;
        private string _province;
        private string _scale;
        private string _software;
        private string _technology;
        private Guid _userID;
        private DateTime _vendorModerateDate;
        private short _vendorModerateStatus;
        private Guid _vendorModerateUser;
        private string _webSite;
    }
}

